package com.czk.originfeign.config;

import com.czk.originfeign.service.RemoteService;
import feign.Feign;
import feign.Request;
import feign.Retryer;
import feign.jackson.JacksonDecoder;
import feign.jackson.JacksonEncoder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author:ChenZhangKun
 * @Date: 2021/8/10 17:21
 */
@Configuration
public class FeignConfig {
    @Bean
    public RemoteService config() {
        return Feign.builder()
                // 指定连接超时时长及响应超时时长
                .options(new Request.Options(100, 3500))
                // 指定重试策略
                .retryer(new Retryer.Default(500, 500, 3))
                .encoder(new JacksonEncoder())
                .decoder(new JacksonDecoder())
                // 绑定接口与服务端地址
                .target(RemoteService.class, "http://localhost:8083/czk");
    }
}
